package edu.yourl.domain;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

@SuppressWarnings("serial")
abstract public class Gossiper implements Favoritable {

	protected List<Gossip> gossips;
	
	protected String seoFriendlyId;

	public Gossiper() {
		this.gossips = new ArrayList<Gossip>();
	}
	
	public void addGossip(Gossip gossip) {
		gossips.add(0, gossip);		
	}
	
	public List<Gossip> getGossips() {
		return Collections.unmodifiableList(gossips);
	}

	@Override
	public String toString() {
		return getFavoritableName();
	}
	
	@Override
	public String getSEOFriendlyId() {
		return this.seoFriendlyId;
	}

	//TODO improve this method. take care about special chars, etc
	protected String slugify(String favoritableName) {
		String slugified = favoritableName;
		slugified = slugified.replaceAll("http(?:s)?://", "");
		slugified = slugified.replace("/", "-");
		return slugified;
	}
}
